# import os
# import pytest
# import requests
# from common.tools import md5_code, trans_str
# from common.datas import get_data
# from common.consts import DATA_PATH
#
# data_file = os.path.join(DATA_PATH, "test_zhuce_ysmm.yaml")
# data = get_data(data_file)
#
# '''1原始密码注册'''
# class TestZhuceYsmm():
#     '''原始密码注册'''
#     @pytest.mark.parametrize("datas",data)
#     def test_app_zhuce_ok_001(self,datas):
#         '''原始密码注册'''
#
#         url =datas.get('url')
#         method = datas.get('method')
#         payload = datas.get('payload')
#         check = datas.get('check')
#
#         if method == 'POST':
#             r = requests.get(url, params=payload)
#         else:
#             r = requests.post(url, data=payload)
#         r_body = trans_str(r.text)
#         for c in check:
#             assert c in r_body
#
#
# ''''''
#     '''2原始密码注册用户名英文'''
#     def test_app_zhuce_ok_002(self,datas):
#         '''原始密码注册用户名英文'''
#         #准备数据
#         url = "http://hn216.api.yesapi.cn/api/App/User/RegisterExt"
#         payload = {
#             "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
#             "username": "one",
#             "password": "568921782"
#         }
#         # 发送请求
#         r = requests.post(url=url, data=payload)
#         # 解析响应断言
#         body = r.json()
#         ret = body.get("ret")
#         err_code = body.get("data").get("err_code")
#         err_msg = body.get("data").get("err_msg")
#         uuid = body.get("data").get("uuid")
#
#         #断言
#         assert 200 == ret,"ret的值为{}".format(ret)
#         assert 0 == err_code
#         assert "" == err_msg
#         assert uuid != ""
#
#     '''3原始密码注册用户名含特殊字符'''
#     def test_app_zhuce_ok_003(self):
#         '''原始密码注册用户名含特殊字符'''
#         #准备数据
#         url = "http://hn216.api.yesapi.cn/api/App/User/RegisterExt"
#         payload = {
#             "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
#             "username": "！@#￥%￥%…………",
#             "password": "568921782"
#         }
#         # 发送请求
#         r = requests.post(url=url, data=payload)
#         # 解析响应断言
#         body = r.json()
#         ret = body.get("ret")
#         err_code = body.get("data").get("err_code")
#         err_msg = body.get("data").get("err_msg")
#         uuid = body.get("data").get("uuid")
#
#         #断言
#         assert 200 == ret,"ret的值为{}".format(ret)
#         assert 0 == err_code
#         assert "" == err_msg
#         assert uuid != ""
#
#     '''4原始密码注册用户名中英文结合'''
#     def test_app_zhuce_ok_004(self):
#         '''原始密码注册用户名中英文结合'''
#         #准备数据
#         url = "http://hn216.api.yesapi.cn/api/App/User/RegisterExt"
#         payload = {
#             "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
#             "username": "你好hello",
#             "password": "568921782"
#         }
#         # 发送请求
#         r = requests.post(url=url, data=payload)
#         # 解析响应断言
#         body = r.json()
#         ret = body.get("ret")
#         err_code = body.get("data").get("err_code")
#         err_msg = body.get("data").get("err_msg")
#         uuid = body.get("data").get("uuid")
#
#         #断言
#         assert 200 == ret,"ret的值为{}".format(ret)
#         assert 0 == err_code
#         assert "" == err_msg
#         assert uuid != ""
#
#     '''5原始密码注册用户名数字'''
#     def test_app_zhuce_ok_005(self):
#         '''原始密码注册用户名数字'''
#         #准备数据
#         url = "http://hn216.api.yesapi.cn/api/App/User/RegisterExt"
#         payload = {
#             "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
#             "username": "123456",
#             "password": "568921782"
#         }
#         # 发送请求
#         r = requests.post(url=url, data=payload)
#         # 解析响应断言
#         body = r.json()
#         ret = body.get("ret")
#         err_code = body.get("data").get("err_code")
#         err_msg = body.get("data").get("err_msg")
#         uuid = body.get("data").get("uuid")
#
#         #断言
#         assert 200 == ret,"ret的值为{}".format(ret)
#         assert 0 == err_code
#         assert "" == err_msg
#         assert uuid != ""
#
#     '''6原始密码注册用户名达下限'''
#     def test_app_zhuce_ok_006(self):
#         '''原始密码注册用户名达下限'''
#         #准备数据
#         url = "http://hn216.api.yesapi.cn/api/App/User/RegisterExt"
#         payload = {
#             "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
#             "username": "1",
#             "password": "568921782"
#         }
#         # 发送请求
#         r = requests.post(url=url, data=payload)
#         # 解析响应断言
#         body = r.json()
#         ret = body.get("ret")
#         err_code = body.get("data").get("err_code")
#         err_msg = body.get("data").get("err_msg")
#         uuid = body.get("data").get("uuid")
#
#         #断言
#         assert 200 == ret,"ret的值为{}".format(ret)
#         assert 0 == err_code
#         assert "" == err_msg
#         assert uuid != ""
#
#     '''7原始密码注册用户名达上限'''
#     def test_app_zhuce_ok_007(self):
#         '''原始密码注册用户名达上限'''
#         #准备数据
#         url = "http://hn216.api.yesapi.cn/api/App/User/RegisterExt"
#         payload = {
#             "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
#             "username": "你好你好你好你好你好你你好你好你好你好你好你好你好你好你好你好你好你好你好你你你好你好你好你好你好你",
#             "password": "568921782"
#         }
#         # 发送请求
#         r = requests.post(url=url, data=payload)
#         # 解析响应断言
#         body = r.json()
#         ret = body.get("ret")
#         err_code = body.get("data").get("err_code")
#         err_msg = body.get("data").get("err_msg")
#         uuid = body.get("data").get("uuid")
#
#         #断言
#         assert 200 == ret,"ret的值为{}".format(ret)
#         assert 0 == err_code
#         assert "" == err_msg
#         assert uuid != ""
#
#     '''8原始密码注册密码达下限'''
#     def test_app_zhuce_ok_008(self):
#         '''原始密码注册密码达下限'''
#         #准备数据
#         url = "http://hn216.api.yesapi.cn/api/App/User/RegisterExt"
#         payload = {
#             "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
#             "username": "水电费付付5",
#             "password": "5"
#         }
#         # 发送请求
#         r = requests.post(url=url, data=payload)
#         # 解析响应断言
#         body = r.json()
#         ret = body.get("ret")
#         err_code = body.get("data").get("err_code")
#         err_msg = body.get("data").get("err_msg")
#         uuid = body.get("data").get("uuid")
#
#         #断言
#         assert 200 == ret,"ret的值为{}".format(ret)
#         assert 0 == err_code
#         assert "" == err_msg
#         assert uuid != ""
#
#     '''9原始密码注册密码达上限'''
#     def test_app_zhuce_ok_009(self):
#         '''原始密码注册密码达上限'''
#         #准备数据
#         url = "http://hn216.api.yesapi.cn/api/App/User/RegisterExt"
#         payload = {
#             "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
#             "username": "密码上限",
#             "password": "12345678911234567891123456789112345678911234567891"
#         }
#         # 发送请求
#         r = requests.post(url=url, data=payload)
#         # 解析响应断言
#         body = r.json()
#         ret = body.get("ret")
#         err_code = body.get("data").get("err_code")
#         err_msg = body.get("data").get("err_msg")
#         uuid = body.get("data").get("uuid")
#
#         #断言
#         assert 200 == ret,"ret的值为{}".format(ret)
#         assert 0 == err_code
#         assert "" == err_msg
#         assert uuid != ""
#
#     '''10原始密码注册密码为中文'''
#     def test_app_zhuce_ok_010(self):
#         '''原始密码注册密码为中文'''
#         #准备数据
#         url = "http://hn216.api.yesapi.cn/api/App/User/RegisterExt"
#         payload = {
#             "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
#             "username": "密码中文的",
#             "password": "中文密码"
#         }
#         # 发送请求
#         r = requests.post(url=url, data=payload)
#         # 解析响应断言
#         body = r.json()
#         ret = body.get("ret")
#         err_code = body.get("data").get("err_code")
#         err_msg = body.get("data").get("err_msg")
#         uuid = body.get("data").get("uuid")
#
#         #断言
#         assert 200 == ret,"ret的值为{}".format(ret)
#         assert 0 == err_code
#         assert "" == err_msg
#         assert uuid != ""
#
#     '''11原始密码注册密码为中英文'''
#     def test_app_zhuce_ok_011(self):
#         '''原始密码注册密码为中英文'''
#         #准备数据
#         url = "http://hn216.api.yesapi.cn/api/App/User/RegisterExt"
#         payload = {
#             "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
#             "username": "密码中文的好",
#             "password": "中文hello"
#         }
#         # 发送请求
#         r = requests.post(url=url, data=payload)
#         # 解析响应断言
#         body = r.json()
#         ret = body.get("ret")
#         err_code = body.get("data").get("err_code")
#         err_msg = body.get("data").get("err_msg")
#         uuid = body.get("data").get("uuid")
#
#         #断言
#         assert 200 == ret,"ret的值为{}".format(ret)
#         assert 0 == err_code
#         assert "" == err_msg
#         assert uuid != ""
#
#
#
#
#     '''12原始密码注册重复用户名'''
#     def test_app_zhuce_no_012(self):
#         '''原始密码注册重复用户名'''
#         #准备数据
#         url = "http://hn216.api.yesapi.cn/api/App/User/RegisterExt"
#         payload = {
#             "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
#             "username": "密码中文的好",
#             "password": "123456"
#         }
#         # 发送请求
#         r = requests.post(url=url, data=payload)
#         # 解析响应断言
#         body = r.json()
#         ret = body.get("ret")
#         err_code = body.get("data").get("err_code")
#         err_msg = body.get("data").get("err_msg")
#         uuid = body.get("data").get("uuid")
#
#         #断言
#         assert 200 == ret, "ret的值为{}".format(ret)
#         assert 1 == err_code
#         assert uuid == ""
#         assert "用户已注册，不能重复注册" in err_msg
#
#     '''13原始密码注册app_key为空注册'''
#     def test_app_zhuce_no_013(self):
#         '''原始密码注册app_key为空注册'''
#         #准备数据
#         url = "http://hn216.api.yesapi.cn/api/App/User/RegisterExt"
#         payload = {
#             "app_key": "",
#             "username": "原始密码注册",
#             "password": "568921782"
#         }
#         # 发送请求
#         r = requests.post(url=url, data=payload)
#         # 解析响应断言
#         body = r.json()
#         ret = body.get("ret")
#         msg = body.get('msg')
#
#         #断言
#         assert 400 == ret,"ret的值为{}".format(ret)
#         assert "客户端非法请求" in msg
#
#     '''14原始密码注册app_key含空格'''
#     def test_app_zhuce_no_014(self):
#         '''原始密码注册app_key含空格'''
#
#         #准备数据
#         url = "http://hn216.api.yesapi.cn/api/App/User/RegisterExt"
#         payload = {
#             "app_key": "06 16B E0ACE 6C975 88C  EA4B 9B7C8F 3BC7",
#             "username": "原始密码注册",
#             "password": "568921782"
#         }
#         # 发送请求
#         r = requests.post(url=url, data=payload)
#         # 解析响应断言
#         body = r.json()
#         ret = body.get("ret")
#         msg = body.get('msg')
#
#         #断言
#         assert 406 == ret,"ret的值为{}".format(ret)
#         assert "客户端非法请求" in msg
#
#     '''15原始密码注册app_key含中文'''
#     def test_app_zhuce_no_015(self):
#         '''原始密码注册app_key含中文'''
#
#         #准备数据
#         url = "http://hn216.api.yesapi.cn/api/App/User/RegisterExt"
#         payload = {
#             "app_key": "0616BE0ACE6C9好88CEA4B9好C8F3B好",
#             "username": "原始密码注册",
#             "password": "568921782"
#         }
#         # 发送请求
#         r = requests.post(url=url, data=payload)
#         # 解析响应断言
#         body = r.json()
#         ret = body.get("ret")
#         msg = body.get('msg')
#
#         #断言
#         assert 406 == ret,"ret的值为{}".format(ret)
#         assert "客户端非法请求" in msg
#
#     '''16原始密码注册app_key含特殊符号'''
#     def test_app_zhuce_no_016(self):
#         '''原始密码注册app_key含特殊符号'''
#
#         #准备数据
#         url = "http://hn216.api.yesapi.cn/api/App/User/RegisterExt"
#         payload = {
#             "app_key": "061%E0ACE￥97@8CEA4B9B7C8F3B！",
#             "username": "原始密码注册",
#             "password": "568921782"
#         }
#         # 发送请求
#         r = requests.post(url=url, data=payload)
#         # 解析响应断言
#         body = r.json()
#         ret = body.get("ret")
#         msg = body.get('msg')
#
#         #断言
#         assert 406 == ret,"ret的值为{}".format(ret)
#         assert "客户端非法请求" in msg
#
#     '''17原始密码注册app_key超上限'''
#     def test_app_zhuce_no_017(self):
#         '''原始密码注册app_key超上限'''
#
#         #准备数据
#         url = "http://hn216.api.yesapi.cn/api/App/User/RegisterExt"
#         payload = {
#             "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC71",
#             "username": "原始密码注册",
#             "password": "568921782"
#         }
#         # 发送请求
#         r = requests.post(url=url, data=payload)
#         # 解析响应断言
#         body = r.json()
#         ret = body.get("ret")
#         msg = body.get('msg')
#
#         #断言
#         assert 406 == ret,"ret的值为{}".format(ret)
#         assert "客户端非法请求" in msg
#
#     '''18原始密码注册用户名超上限'''
#     def test_app_zhuce_no_018(self):
#         '''原始密码注册用户名超上限'''
#         #准备数据
#         url = "http://hn216.api.yesapi.cn/api/App/User/RegisterExt"
#         payload = {
#             "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC71",
#             "username": "你好你好你好你好你好你你好你好你好你好你好你好你好你好你好你好你好你好你好你你你好你好你好你好你好你好",
#             "password": "568921782"
#         }
#         # 发送请求
#         r = requests.post(url=url, data=payload)
#         # 解析响应断言
#         body = r.json()
#         ret = body.get("ret")
#         msg = body.get('msg')
#
#         #断言
#         assert 400 == ret,"ret的值为{}".format(ret)
#         assert "客户端非法请求" in msg
#
#     '''19原始密码注册密码超上限'''
#     def test_app_zhuce_no_019(self):
#         '''原始密码注册密码超上限'''
#         #准备数据
#         url = "http://hn216.api.yesapi.cn/api/App/User/RegisterExt"
#         payload = {
#             "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
#             "username": "你好你好",
#             "password": "你好你好你好你好你好你你好你好你好你好你好你好你好你好你好你好你好你好你好你你你好你好你规格个非非非好"
#         }
#         # 发送请求
#         r = requests.post(url=url, data=payload)
#         # 解析响应断言
#         body = r.json()
#         ret = body.get("ret")
#         msg = body.get('msg')
#
#         #断言
#         assert 400 == ret,"ret的值为{}".format(ret)
#         assert "客户端非法请求" in msg
#
#     '''20原始密码注册用户名为空'''
#     def test_app_zhuce_no_020(self):
#         '''原始密码注册用户名为空'''
#         #准备数据
#         url = "http://hn216.api.yesapi.cn/api/App/User/RegisterExt"
#         payload = {
#             "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
#             "username": "",
#             "password": "你好你好你好你好你好你你好你好你好你好你好你好你好你好你好你好你好你好你好你你你好你好你规格个非非非好"
#         }
#         # 发送请求
#         r = requests.post(url=url, data=payload)
#         # 解析响应断言
#         body = r.json()
#         ret = body.get("ret")
#         msg = body.get('msg')
#
#         #断言
#         assert 400 == ret,"ret的值为{}".format(ret)
#         assert "客户端非法请求" in msg
#
#     '''21原始密码注册密码为空'''
#     def test_app_zhuce_no_021(self):
#         '''原始密码注册密码为空'''
#         #准备数据
#         url = "http://hn216.api.yesapi.cn/api/App/User/RegisterExt"
#         payload = {
#             "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
#             "username": "密码为空",
#             "password": ""
#         }
#         # 发送请求
#         r = requests.post(url=url, data=payload)
#         # 解析响应断言
#         body = r.json()
#         ret = body.get("ret")
#         msg = body.get('msg')
#
#         #断言
#         assert 400 == ret,"ret的值为{}".format(ret)
#         assert "客户端非法请求" in msg
# ''''''
#
# if __name__ == '__main__':
#     pytest.main(["-s",__file__])





import requests
import pytest

'''正常注册'''
class TestAppzhuce():
    '''正常注册'''
    def test_app_zhuce_ok_001(self):
        '''正常注册'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/Register"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
            "username": "原始密码注册3",
            "password": "456f15113e2f0d3e4a188feb3fffdeec"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        err_code = body.get("data").get("err_code")
        err_msg = body.get("data").get("err_msg")
        uuid = body.get("data").get("uuid")

        #断言
        assert 200 == ret,"ret的值为{}".format(ret)
        assert 0 == err_code
        assert "" == err_msg
        assert uuid != ""

    '''注册用户名英文'''
    def test_app_zhuce_ok_002(self):
        '''注册用户名英文'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/Register"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
            "username": "onetwo",
            "password": "456f15113e2f0d3e4a188feb3fffdeec"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        err_code = body.get("data").get("err_code")
        err_msg = body.get("data").get("err_msg")
        uuid = body.get("data").get("uuid")

        #断言
        assert 200 == ret,"ret的值为{}".format(ret)
        assert 0 == err_code
        assert "" == err_msg
        assert uuid != ""


    '''注册用户名含特殊字符'''
    def test_app_zhuce_ok_003(self):
        '''注册用户名含特殊字符'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/Register"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
            "username": "！@#￥%￥%…………@",
            "password": "456f15113e2f0d3e4a188feb3fffdeec"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        err_code = body.get("data").get("err_code")
        err_msg = body.get("data").get("err_msg")
        uuid = body.get("data").get("uuid")

        #断言
        assert 200 == ret,"ret的值为{}".format(ret)
        assert 0 == err_code
        assert "" == err_msg
        assert uuid != ""


    '''注册用户名中英文结合'''
    def test_app_zhuce_ok_004(self):
        '''注册用户名中英文结合'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/Register"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
            "username": "你好helloon",
            "password": "456f15113e2f0d3e4a188feb3fffdeec"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        err_code = body.get("data").get("err_code")
        err_msg = body.get("data").get("err_msg")
        uuid = body.get("data").get("uuid")

        #断言
        assert 200 == ret,"ret的值为{}".format(ret)
        assert 0 == err_code
        assert "" == err_msg
        assert uuid != ""


    '''注册用户名数字'''
    def test_app_zhuce_ok_005(self):
        '''注册用户名数字'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/Register"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
            "username": "1234567",
            "password": "456f15113e2f0d3e4a188feb3fffdeec"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        err_code = body.get("data").get("err_code")
        err_msg = body.get("data").get("err_msg")
        uuid = body.get("data").get("uuid")

        #断言
        assert 200 == ret,"ret的值为{}".format(ret)
        assert 0 == err_code
        assert "" == err_msg
        assert uuid != ""


    '''注册用户名达下限'''
    def test_app_zhuce_ok_006(self):
        '''注册用户名达下限'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/Register"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
            "username": "唉",
            "password": "456f15113e2f0d3e4a188feb3fffdeec"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        err_code = body.get("data").get("err_code")
        err_msg = body.get("data").get("err_msg")
        uuid = body.get("data").get("uuid")

        #断言
        assert 200 == ret,"ret的值为{}".format(ret)
        assert 0 == err_code
        assert "" == err_msg
        assert uuid != ""


    '''注册用户名达上限'''
    def test_app_zhuce_ok_007(self):
        '''注册用户名达上限'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/Register"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
            "username": "你好你好你好你好你好你你好你好你好你好你好你好你好你好你好你好你好你好你好你你你好你好你好你好你好哦",
            "password": "456f15113e2f0d3e4a188feb3fffdeec"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        err_code = body.get("data").get("err_code")
        err_msg = body.get("data").get("err_msg")
        uuid = body.get("data").get("uuid")

        #断言
        assert 200 == ret,"ret的值为{}".format(ret)
        assert 0 == err_code
        assert "" == err_msg
        assert uuid != ""


    '''注册密码达下限'''
    def test_app_zhuce_ok_008(self):
        '''注册密码达下限'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/Register"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
            "username": "水电费付5",
            "password": "c81e728d9d4c2f636f067f89cc14862c"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        err_code = body.get("data").get("err_code")
        err_msg = body.get("data").get("err_msg")
        uuid = body.get("data").get("uuid")

        #断言
        assert 200 == ret,"ret的值为{}".format(ret)
        assert 0 == err_code
        assert "" == err_msg
        assert uuid != ""


    '''注册密码达上限'''
    def test_app_zhuce_ok_009(self):
        '''注册密码达上限'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/Register"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
            "username": "密码上限9",
            "password": "1cba8bd1e9b7fb2cc0d9a61221d7d739"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        err_code = body.get("data").get("err_code")
        err_msg = body.get("data").get("err_msg")
        uuid = body.get("data").get("uuid")

        #断言
        assert 200 == ret,"ret的值为{}".format(ret)
        assert 0 == err_code
        assert "" == err_msg
        assert uuid != ""


    '''注册密码为中文'''
    def test_app_zhuce_ok_010(self):
        '''注册密码为中文'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/Register"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
            "username": "密码中文的5",
            "password": "3d4acf94adca8562b4990599b15488de"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        err_code = body.get("data").get("err_code")
        err_msg = body.get("data").get("err_msg")
        uuid = body.get("data").get("uuid")

        #断言
        assert 200 == ret,"ret的值为{}".format(ret)
        assert 0 == err_code
        assert "" == err_msg
        assert uuid != ""


    '''注册密码为中英文'''
    def test_app_zhuce_ok_011(self):
        '''注册密码为中英文'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/Register"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
            "username": "密码中文的好哦",
            "password": "878450a797d671e43cc656b97c7bddd8"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        err_code = body.get("data").get("err_code")
        err_msg = body.get("data").get("err_msg")
        uuid = body.get("data").get("uuid")

        #断言
        assert 200 == ret,"ret的值为{}".format(ret)
        assert 0 == err_code
        assert "" == err_msg
        assert uuid != ""





    '''注册重复用户名'''
    def test_app_zhuce_no_012(self):
        '''注册重复用户名'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/Register"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
            "username": "密码中文的好",
            "password": "878450a797d671e43cc656b97c7bddd8"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        err_code = body.get("data").get("err_code")
        err_msg = body.get("data").get("err_msg")
        uuid = body.get("data").get("uuid")

        #断言
        assert 200 == ret, "ret的值为{}".format(ret)
        assert 1 == err_code
        assert uuid == ""
        assert "用户已注册，不能重复注册" in err_msg


    '''注册app_key为空注册'''
    def test_app_zhuce_no_013(self):
        '''注册app_key为空注册'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/Register"
        payload = {
            "app_key": "",
            "username": "为空",
            "password": "878450a797d671e43cc656b97c7bddd8"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        msg = body.get('msg')

        #断言
        assert 400 == ret,"ret的值为{}".format(ret)
        assert "客户端非法请求" in msg


    '''注册app_key含空格'''
    def test_app_zhuce_no_014(self):
        '''注册app_key含空格'''

        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/Register"
        payload = {
            "app_key": "06 16B E0ACE 6C975 88C  EA4B 9B7C8F 3BC7",
            "username": "app_key含空格0",
            "password": "878450a797d671e43cc656b97c7bddd8"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        msg = body.get('msg')

        #断言
        assert 406 == ret,"ret的值为{}".format(ret)
        assert "客户端非法请求" in msg


    '''注册app_key含中文'''
    def test_app_zhuce_no_015(self):
        '''注册app_key含中文'''

        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/Register"
        payload = {
            "app_key": "0616BE0ACE6C9好88CEA4B9好C8F3B好",
            "username": "key含中文",
            "password": "878450a797d671e43cc656b97c7bddd8"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        msg = body.get('msg')

        #断言
        assert 406 == ret,"ret的值为{}".format(ret)
        assert "客户端非法请求" in msg


    '''注册app_key含特殊符号'''
    def test_app_zhuce_no_016(self):
        '''注册app_key含特殊符号'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/Register"
        payload = {
            "app_key": "061%E0ACE￥97@8CEA4B9B7C8F3B！",
            "username": "特殊符号",
            "password": "878450a797d671e43cc656b97c7bddd8"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        msg = body.get('msg')

        #断言
        assert 406 == ret,"ret的值为{}".format(ret)
        assert "客户端非法请求" in msg


    '''注册app_key超上限'''
    def test_app_zhuce_no_017(self):
        '''注册app_key超上限'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/Register"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC70",
            "username": "key超上限",
            "password": "878450a797d671e43cc656b97c7bddd8"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        msg = body.get('msg')

        #断言
        assert 406 == ret,"ret的值为{}".format(ret)
        assert "客户端非法请求" in msg


    '''注册用户名超上限'''
    def test_app_zhuce_no_018(self):
        '''注册用户名超上限'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/Register"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
            "username": "你好你好你好你好你好你你好你好你好你好你好你好你好你好你好你好你好你好你好你你你好你好你好你好你好你好",
            "password": "878450a797d671e43cc656b97c7bddd8"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        msg = body.get('msg')

        #断言
        assert 400 == ret,"ret的值为{}".format(ret)
        assert "客户端非法请求" in msg


    '''注册密码超上限'''
    def test_app_zhuce_no_019(self):
        '''注册密码超上限'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/Register"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
            "username": "密码超上限86",
            "password": "f561e5e9f793ecccca79a04a79a1b888"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        msg = body.get('msg')

        #断言
        assert 400 == ret,"ret的值为{}".format(ret)
        assert "客户端非法请求" in msg


    '''注册用户名为空'''
    def test_app_zhuce_no_020(self):
        '''注册用户名为空'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/Register"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
            "username": "",
            "password": "878450a797d671e43cc656b97c7bddd8"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        msg = body.get('msg')

        #断言
        assert 400 == ret,"ret的值为{}".format(ret)
        assert "客户端非法请求" in msg


    '''注册密码为空'''
    def test_app_zhuce_no_021(self):
        '''注册密码为空'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/Register"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
            "username": "密码为空",
            "password": ""
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        msg = body.get('msg')

        #断言
        assert 400 == ret,"ret的值为{}".format(ret)
        assert "客户端非法请求" in msg


    '''注册密码为，加密空格'''
    def test_app_zhuce_no_022(self):
        '''注册密码为加密空格'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/Register"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
            "username": "密码为加密空格0",
            "password": "dcd42d4c7659a19bd7ef6e2b44db28a0"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        err_code = body.get("data").get("err_code")
        err_msg = body.get("data").get("err_msg")
        uuid = body.get("data").get("uuid")

        #断言
        assert 200 == ret,"ret的值为{}".format(ret)
        assert 0 == err_code
        assert "" == err_msg
        assert uuid != ""

if __name__ == '__main__':
    pytest.main([__file__])







import requests
import pytest

class TestAppUserLogin():
    '''正常登录'''
    def test_app_login_ok_01(self):
        '''正常登录'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/Login"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
            "username": "原始密码注册3",
            "password": "456f15113e2f0d3e4a188feb3fffdeec"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        err_code = body.get("data").get("err_code")
        err_msg = body.get("data").get("err_msg")
        uuid = body.get("data").get("uuid")
        token = body.get("data").get("token")

        #断言
        assert 200 == ret,"ret的值为{}".format(ret)
        assert 0 == err_code
        assert "" == err_msg
        assert uuid != ""
        assert token != ""


    '''用户名达上限登录'''
    def test_app_login_ok_02(self):
        '''用户名达上限登录'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/Login"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
            "username": "你好你好你好你好你好你你好你好你好你好你好你好你好你好你好你好你好你好你好你你你好你好你好你好你好哦",
            "password": "456f15113e2f0d3e4a188feb3fffdeec"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        err_code = body.get("data").get("err_code")
        err_msg = body.get("data").get("err_msg")
        uuid = body.get("data").get("uuid")
        token = body.get("data").get("token")

        #断言
        assert 200 == ret,"ret的值为{}".format(ret)
        assert 0 == err_code
        assert "" == err_msg
        assert uuid != ""
        assert token != ""


    '''用户名达下限登录'''
    def test_app_login_ok_03(self):
        '''用户名达上限登录'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/Login"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
            "username": "水电费付5",
            "password": "c81e728d9d4c2f636f067f89cc14862c"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        err_code = body.get("data").get("err_code")
        err_msg = body.get("data").get("err_msg")
        uuid = body.get("data").get("uuid")
        token = body.get("data").get("token")

        #断言
        assert 200 == ret,"ret的值为{}".format(ret)
        assert 0 == err_code
        assert "" == err_msg
        assert uuid != ""
        assert token != ""


    '''密码达上限限登录'''
    def test_app_login_ok_04(self):
        '''密码达上限限登录'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/Login"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
            "username": "密码上限9",
            "password": "1cba8bd1e9b7fb2cc0d9a61221d7d739"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        err_code = body.get("data").get("err_code")
        err_msg = body.get("data").get("err_msg")
        uuid = body.get("data").get("uuid")
        token = body.get("data").get("token")

        #断言
        assert 200 == ret,"ret的值为{}".format(ret)
        assert 0 == err_code
        assert "" == err_msg
        assert uuid != ""
        assert token != ""


    '''密码达下限登录'''
    def test_app_login_ok_05(self):
        '''密码达下限登录'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/Login"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
            "username": "水电费付5",
            "password": "c81e728d9d4c2f636f067f89cc14862c"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        err_code = body.get("data").get("err_code")
        err_msg = body.get("data").get("err_msg")
        uuid = body.get("data").get("uuid")
        token = body.get("data").get("token")

        #断言
        assert 200 == ret,"ret的值为{}".format(ret)
        assert 0 == err_code
        assert "" == err_msg
        assert uuid != ""
        assert token != ""


    '''用户名英文登录'''
    def test_app_login_ok_06(self):
        '''用户名英文登录'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/Login"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
            "username": "onetwo",
            "password": "456f15113e2f0d3e4a188feb3fffdeec"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        err_code = body.get("data").get("err_code")
        err_msg = body.get("data").get("err_msg")
        uuid = body.get("data").get("uuid")
        token = body.get("data").get("token")

        #断言
        assert 200 == ret,"ret的值为{}".format(ret)
        assert 0 == err_code
        assert "" == err_msg
        assert uuid != ""
        assert token != ""


    '''用户名特殊字符登录'''
    def test_app_login_ok_07(self):
        '''用户名特殊字符登录'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/Login"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
            "username": "！@#￥%￥%…………@",
            "password": "456f15113e2f0d3e4a188feb3fffdeec"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        err_code = body.get("data").get("err_code")
        err_msg = body.get("data").get("err_msg")
        uuid = body.get("data").get("uuid")
        token = body.get("data").get("token")

        #断言
        assert 200 == ret,"ret的值为{}".format(ret)
        assert 0 == err_code
        assert "" == err_msg
        assert uuid != ""
        assert token != ""


    '''用户名中英文登录'''
    def test_app_login_ok_08(self):
        '''用户名中英文登录'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/Login"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
            "username": "你好helloon",
            "password": "456f15113e2f0d3e4a188feb3fffdeec"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        err_code = body.get("data").get("err_code")
        err_msg = body.get("data").get("err_msg")
        uuid = body.get("data").get("uuid")
        token = body.get("data").get("token")

        #断言
        assert 200 == ret,"ret的值为{}".format(ret)
        assert 0 == err_code
        assert "" == err_msg
        assert uuid != ""
        assert token != ""


    '''用户名数字登录'''
    def test_app_login_ok_09(self):
        '''用户名数字登录'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/Login"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
            "username": "1234567",
            "password": "456f15113e2f0d3e4a188feb3fffdeec"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        err_code = body.get("data").get("err_code")
        err_msg = body.get("data").get("err_msg")
        uuid = body.get("data").get("uuid")
        token = body.get("data").get("token")

        #断言
        assert 200 == ret,"ret的值为{}".format(ret)
        assert 0 == err_code
        assert "" == err_msg
        assert uuid != ""
        assert token != ""


    '''密码为中英文登录'''
    def test_app_login_ok_10(self):
        '''密码为中英文登录'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/Login"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
            "username": "密码中文的好哦",
            "password": "878450a797d671e43cc656b97c7bddd8"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        err_code = body.get("data").get("err_code")
        err_msg = body.get("data").get("err_msg")
        uuid = body.get("data").get("uuid")
        token = body.get("data").get("token")

        #断言
        assert 200 == ret,"ret的值为{}".format(ret)
        assert 0 == err_code
        assert "" == err_msg
        assert uuid != ""
        assert token != ""




    '''app_key为空登录'''
    def test_app_login_no_11(self):
        '''app_key为空登录'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/Login"
        payload = {
            "app_key": "",
            "username": "1234567",
            "password": "456f15113e2f0d3e4a188feb3fffdeec"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        msg = body.get('msg')

        # 断言
        assert 400 == ret, "ret的值为{}".format(ret)
        assert "客户端非法请求" in msg


    '''app_key含空格登录'''
    def test_app_login_no_12(self):
        '''app_key含空格登录'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/Login"
        payload = {
            "app_key": "06 16B E0ACE 6C975 88C  EA4B 9B7C8F 3BC7",
            "username": "1234567",
            "password": "456f15113e2f0d3e4a188feb3fffdeec"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        msg = body.get('msg')

        # 断言
        assert 406 == ret, "ret的值为{}".format(ret)
        assert "客户端非法请求" in msg


    '''app_key含中文登录'''
    def test_app_login_no_13(self):
        '''app_key含中文登录'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/Login"
        payload = {
            "app_key": "0616BE0ACE6C9好88CEA4B9好C8F3B好",
            "username": "1234567",
            "password": "456f15113e2f0d3e4a188feb3fffdeec"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        msg = body.get('msg')

        # 断言
        assert 406 == ret, "ret的值为{}".format(ret)
        assert "客户端非法请求" in msg


    '''app_key含特殊字符登录'''
    def test_app_login_no_14(self):
        '''app_key含特殊字符登录'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/Login"
        payload = {
            "app_key": "061%E0ACE￥97@8CEA4B9B7C8F3B！",
            "username": "1234567",
            "password": "456f15113e2f0d3e4a188feb3fffdeec"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        msg = body.get('msg')

        # 断言
        assert 406 == ret, "ret的值为{}".format(ret)
        assert "客户端非法请求" in msg


    '''app_key超上限登录'''
    def test_app_login_no_15(self):
        '''app_key超上限登录'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/Login"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC71",
            "username": "1234567",
            "password": "456f15113e2f0d3e4a188feb3fffdeec"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        msg = body.get('msg')

        # 断言
        assert 406 == ret, "ret的值为{}".format(ret)
        assert "客户端非法请求" in msg


    '''用户名超上限登录'''
    def test_app_login_no_16(self):
        '''用户名超上限登录'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/Login"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
            "username": "你好你好你好你好你好你你好你好你好你好你好你好你好你好你好你好你好你好你好你你你好你好你好你好你好你好",
            "password": "878450a797d671e43cc656b97c7bddd8"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        msg = body.get('msg')

        # 断言
        assert 400 == ret, "ret的值为{}".format(ret)
        assert "客户端非法请求" in msg


    '''错误的密码登录'''
    def test_app_login_no_17(self):
        '''错误的密码登录'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/Login"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
            "username": "1234567",
            "password": "456f15113e2f0d3e4a188feb3fffdee8"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        err_code = body.get("data").get("err_code")
        err_msg = body.get("data").get("err_msg")
        uuid = body.get("data").get("uuid")
        token = body.get("data").get("token")

        #断言
        assert 200 == ret,"ret的值为{}".format(ret)
        assert 2 == err_code
        assert "登录失败，密码错误" == err_msg
        assert uuid == ""
        assert token == ""


    '''用户名为空登录'''
    def test_app_login_no_18(self):
        '''密码达上限登录'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/Login"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
            "username": "",
            "password": "878450a797d671e43cc656b97c7bddd8"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        msg = body.get('msg')

        # 断言
        assert 400 == ret, "ret的值为{}".format(ret)
        assert "客户端非法请求" in msg


    '''密码为空登录'''
    def test_app_login_no_19(self):
        '''密码为空登录'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/Login"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
            "username": "1234567",
            "password": ""
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        msg = body.get('msg')

        # 断言
        assert 400 == ret, "ret的值为{}".format(ret)
        assert "客户端非法请求" in msg


    '''错误的用户名登录'''
    def test_app_login_no_20(self):
        '''错误的用户名登录'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/Login"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
            "username": "999",
            "password": "3d4acf94adca8562b4990599b15488de"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        err_code = body.get("data").get("err_code")
        err_msg = body.get("data").get("err_msg")
        uuid = body.get("data").get("uuid")
        token = body.get("data").get("token")

        #断言
        assert 200 == ret,"ret的值为{}".format(ret)
        assert 1 == err_code
        assert "登录失败，账号不存在" == err_msg
        assert uuid == ""
        assert token == ""


if __name__ == '__main__':
    pytest.main(["-s",__file__])







import requests
import pytest

class TestAppUserLogin():
    '''原始密码正常登录'''
    def test_app_login_ok_01(self):
        '''原始密码正常登录'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/LoginExt"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
            "username": "原始密码注册",
            "password": "568921782"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        err_code = body.get("data").get("err_code")
        err_msg = body.get("data").get("err_msg")
        uuid = body.get("data").get("uuid")
        token = body.get("data").get("token")

        #断言
        assert 200 == ret,"ret的值为{}".format(ret)
        assert 0 == err_code
        assert "" == err_msg
        assert uuid != ""
        assert token != ""


    '''原始密码用户名达上限登录'''
    def test_app_login_ok_02(self):
        '''原始密码用户名达上限登录'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/LoginExt"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
            "username": "你好你好你好你好你好你你好你好你好你好你好你好你好你好你好你好你好你好你好你你你好你好你好你好你好你",
            "password": "568921782"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        err_code = body.get("data").get("err_code")
        err_msg = body.get("data").get("err_msg")
        uuid = body.get("data").get("uuid")
        token = body.get("data").get("token")

        #断言
        assert 200 == ret,"ret的值为{}".format(ret)
        assert 0 == err_code
        assert "" == err_msg
        assert uuid != ""
        assert token != ""


    '''原始密码用户名达下限登录'''
    def test_app_login_ok_03(self):
        '''原始密码用户名达上限登录'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/LoginExt"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
            "username": "1",
            "password": "568921782"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        err_code = body.get("data").get("err_code")
        err_msg = body.get("data").get("err_msg")
        uuid = body.get("data").get("uuid")
        token = body.get("data").get("token")

        #断言
        assert 200 == ret,"ret的值为{}".format(ret)
        assert 0 == err_code
        assert "" == err_msg
        assert uuid != ""
        assert token != ""


    '''原始密码，密码达上限限登录'''
    def test_app_login_ok_04(self):
        '''原始密码，密码达上限限登录'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/LoginExt"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
            "username": "密码上限",
            "password": "12345678911234567891123456789112345678911234567891"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        err_code = body.get("data").get("err_code")
        err_msg = body.get("data").get("err_msg")
        uuid = body.get("data").get("uuid")
        token = body.get("data").get("token")

        #断言
        assert 200 == ret,"ret的值为{}".format(ret)
        assert 0 == err_code
        assert "" == err_msg
        assert uuid != ""
        assert token != ""


    '''原始密码，密码达下限登录'''
    def test_app_login_ok_05(self):
        '''原始密码，密码达下限登录'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/LoginExt"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
            "username": "水电费付付5",
            "password": "5"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        err_code = body.get("data").get("err_code")
        err_msg = body.get("data").get("err_msg")
        uuid = body.get("data").get("uuid")
        token = body.get("data").get("token")

        #断言
        assert 200 == ret,"ret的值为{}".format(ret)
        assert 0 == err_code
        assert "" == err_msg
        assert uuid != ""
        assert token != ""


    '''原始密码，用户名英文登录'''
    def test_app_login_ok_06(self):
        '''原始密码，用户名英文登录'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/LoginExt"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
            "username": "one",
            "password": "568921782"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        err_code = body.get("data").get("err_code")
        err_msg = body.get("data").get("err_msg")
        uuid = body.get("data").get("uuid")
        token = body.get("data").get("token")

        #断言
        assert 200 == ret,"ret的值为{}".format(ret)
        assert 0 == err_code
        assert "" == err_msg
        assert uuid != ""
        assert token != ""


    '''原始密码，用户名特殊字符登录'''
    def test_app_login_ok_07(self):
        '''原始密码，用户名特殊字符登录'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/LoginExt"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
            "username": "！@#￥%￥%…………",
            "password": "568921782"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        err_code = body.get("data").get("err_code")
        err_msg = body.get("data").get("err_msg")
        uuid = body.get("data").get("uuid")
        token = body.get("data").get("token")

        #断言
        assert 200 == ret,"ret的值为{}".format(ret)
        assert 0 == err_code
        assert "" == err_msg
        assert uuid != ""
        assert token != ""


    '''原始密码，用户名中英文登录'''
    def test_app_login_ok_08(self):
        '''原始密码，用户名中英文登录'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/LoginExt"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
            "username": "你好hello",
            "password": "568921782"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        err_code = body.get("data").get("err_code")
        err_msg = body.get("data").get("err_msg")
        uuid = body.get("data").get("uuid")
        token = body.get("data").get("token")

        #断言
        assert 200 == ret,"ret的值为{}".format(ret)
        assert 0 == err_code
        assert "" == err_msg
        assert uuid != ""
        assert token != ""


    '''原始密码，用户名数字登录'''
    def test_app_login_ok_09(self):
        '''原始密码，用户名数字登录'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/LoginExt"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
            "username": "123456",
            "password": "568921782"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        err_code = body.get("data").get("err_code")
        err_msg = body.get("data").get("err_msg")
        uuid = body.get("data").get("uuid")
        token = body.get("data").get("token")

        #断言
        assert 200 == ret,"ret的值为{}".format(ret)
        assert 0 == err_code
        assert "" == err_msg
        assert uuid != ""
        assert token != ""


    '''原始密码，密码为中英文登录'''
    def test_app_login_ok_10(self):
        '''原始密码，密码为中英文登录'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/LoginExt"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
            "username": "密码中文的好88",
            "password": "中文hello"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        err_code = body.get("data").get("err_code")
        err_msg = body.get("data").get("err_msg")
        uuid = body.get("data").get("uuid")
        token = body.get("data").get("token")

        #断言
        assert 200 == ret,"ret的值为{}".format(ret)
        assert 0 == err_code
        assert "" == err_msg
        assert uuid != ""
        assert token != ""





    '''原始密码，app_key为空登录'''
    def test_app_login_no_11(self):
        '''原始密码，app_key为空登录'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/LoginExt"
        payload = {
            "app_key": "",
            "username": "密码中文的好88",
            "password": "中文hello"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        msg = body.get('msg')

        # 断言
        assert 400 == ret, "ret的值为{}".format(ret)
        assert "客户端非法请求" in msg


    '''原始密码，app_key含空格登录'''
    def test_app_login_no_12(self):
        '''原始密码，app_key含空格登录'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/LoginExt"
        payload = {
            "app_key": "06 16B E0ACE 6C975 88C  EA4B 9B7C8F 3BC7",
            "username": "密码中文的好88",
            "password": "中文hello"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        msg = body.get('msg')

        # 断言
        assert 406 == ret, "ret的值为{}".format(ret)
        assert "客户端非法请求" in msg


    '''原始密码，app_key含中文登录'''
    def test_app_login_no_13(self):
        '''原始密码，app_key含中文登录'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/LoginExt"
        payload = {
            "app_key": "0616BE0ACE6C9好88CEA4B9好C8F3B好",
            "username": "密码中文的好88",
            "password": "中文hello"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        msg = body.get('msg')

        # 断言
        assert 406 == ret, "ret的值为{}".format(ret)
        assert "客户端非法请求" in msg


    '''原始密码，app_key含特殊字符登录'''
    def test_app_login_no_14(self):
        '''原始密码，app_key含特殊字符登录'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/LoginExt"
        payload = {
            "app_key": "061%E0ACE￥97@8CEA4B9B7C8F3B！",
            "username": "密码中文的好88",
            "password": "中文hello"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        msg = body.get('msg')

        # 断言
        assert 406 == ret, "ret的值为{}".format(ret)
        assert "客户端非法请求" in msg


    '''原始密码，app_key超上限登录'''
    def test_app_login_no_15(self):
        '''原始密码，app_key超上限登录'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/LoginExt"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC71",
            "username": "原始密码注册",
            "password": "中文hello"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        msg = body.get('msg')

        # 断言
        assert 406 == ret, "ret的值为{}".format(ret)
        assert "客户端非法请求" in msg


    '''原始密码，用户名超上限登录'''
    def test_app_login_no_16(self):
        '''原始密码，用户名超上限登录'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/LoginExt"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
            "username": "你好你好你好你好你好你你好你好你好你好你好你好你好你好你好你好你好你好你好你你你好你好你好你好你好你好",
            "password": "568921782"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        msg = body.get('msg')

        # 断言
        assert 400 == ret, "ret的值为{}".format(ret)
        assert "客户端非法请求" in msg


    '''原始密码，错误的密码登录'''
    def test_app_login_no_17(self):
        '''原始密码，错误的密码登录'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/LoginExt"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
            "username": "你好你好",
            "password": "你好你好你好你好"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        err_code = body.get("data").get("err_code")
        err_msg = body.get("data").get("err_msg")
        uuid = body.get("data").get("uuid")
        token = body.get("data").get("token")

        #断言
        assert 200 == ret,"ret的值为{}".format(ret)
        assert 2 == err_code
        assert "登录失败，密码错误" == err_msg
        assert uuid == ""
        assert token == ""


    '''原始密码，用户名为空登录'''
    def test_app_login_no_18(self):
        '''原始密码，密码达上限登录'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/LoginExt"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
            "username": "",
            "password": "你好你好你好你好你好你你好你好你好你好你好你好你好你好你好你好你好你好你好你你你好你好你规格个非非非好"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        msg = body.get('msg')

        # 断言
        assert 400 == ret, "ret的值为{}".format(ret)
        assert "客户端非法请求" in msg


    '''原始密码，密码为空登录'''
    def test_app_login_no_19(self):
        '''原始密码，密码为空登录'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/LoginExt"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
            "username": "你好hello",
            "password": ""
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        msg = body.get('msg')

        # 断言
        assert 400 == ret, "ret的值为{}".format(ret)
        assert "客户端非法请求" in msg


    '''原始密码，错误的用户名登录'''
    def test_app_login_no_20(self):
        '''原始密码，错误的用户名登录'''
        #准备数据
        url = "http://hn216.api.yesapi.cn/api/App/User/LoginExt"
        payload = {
            "app_key": "0616BE0ACE6C97588CEA4B9B7C8F3BC7",
            "username": "999",
            "password": "568921782"
        }
        # 发送请求
        r = requests.post(url=url, data=payload)
        # 解析响应断言
        body = r.json()
        ret = body.get("ret")
        err_code = body.get("data").get("err_code")
        err_msg = body.get("data").get("err_msg")
        uuid = body.get("data").get("uuid")
        token = body.get("data").get("token")

        #断言
        assert 200 == ret,"ret的值为{}".format(ret)
        assert 1 == err_code
        assert "登录失败，账号不存在" == err_msg
        assert uuid == ""
        assert token == ""


if __name__ == '__main__':
    pytest.main([__file__])

